@include('Home.head')
<style>
    .layui-upload-img {
        width: 92px;
        height: 92px;
        margin: 0 10px 10px 0;
    }
</style>
<body>
<div class="container" id="app">
     <header data-am-widget="header" class="am-header am-header-default my-header">
        <div class="am-header-left am-header-nav">
            <a  onclick="javascript:history.back(-1);" class="">
                <i class="am-header-icon am-icon-chevron-left"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">@{{ title }}</a>
        </h1>
        <div class="am-header-right am-header-nav">
            <a href="/home/member/index" class="">
                <i class="am-header-icon  am-icon-home"></i>
            </a>
        </div>
    </header>
    <div class="my-nav-bar">
        <ol class="am-breadcrumb">
            <li><a href="/home/stores/index">门店中心</a></li>
            <li><a href="/home/stores/order">订单</a></li>
            <li><a href="#">确认发货</a></li>
        </ol>
    </div>
    <div class="am-cf cart-panel">
        <div class="withdrawals-panel">
            <form class="am-form">
                <div class="am-form-group">
                    <input type="text" class="am-form-field  my-radius" v-model="expressage" placeholder="请填写快递名称">
                </div>
                <div class="am-form-group">
                    <input type="text" class="am-form-field  my-radius" v-model="courier_number" placeholder="请填写快递单号">
                </div>
                <div class="am-form-group">
                    <textarea class="" rows="5" id="doc-ta-1" v-model="remark" placeholder="请输入您的备注"></textarea>
                </div>
                <p class="am-text-center am-form-group"><button type="button" class="am-btn am-btn-danger am-radius am-btn-block" v-on:click="add()">确认发货</button></p>
            </form>
        </div>
    </div>
    @include('Home.foot')
</div>
</body>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            title: '确认发货',
            expressage: '',
            courier_number: '',
            remark: '',
            id:''
         
        },
        methods: {
            initialize:function () {
                var id = this.obtain('id');
                if (id == "" || isNaN( id ) ) {
                    layer.msg("参数错误", {time: 500}, function () {
                        window.location.href="/home/member/index";
                    });
                }
              $.post("/home/stores/stores",{'_token':'{{csrf_token()}}',class:'select',},function (res) {
                if(res.code){
                    app.id = id;
                }
            });
            },
            //确认发货
            add:function () {
                console.log(app.expressage);
                console.log(app.courier_number);
                console.log(app.remark);
                console.log(app.id);
                $.post("/home/stores/stores",{
                    '_token':'{{csrf_token()}}',
                    class:'deliver',
                    id: app.id,
                    expressage: app.expressage,
                    courier_number: app.courier_number,
                    remark: app.remark
                },function (res) {
                    if(res.code){
                        layer.msg(res.data, {time: 500}, function () {
                            window.location.href="/home/stores/order";
                        });
                    } else {
                        layer.msg(res.data);
                    }
                });
            },
            //获取url id
            obtain:function (val) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == val){
                        return pair[1];
                    }
                }
            },
        },
        //自动执行
        mounted: function () {
            this.initialize();//分公司
        }
    })
</script>
</html>
